//here is your code...
summerready = function () {
		
		main.bindEvent();
		//加载第一个页面
		main.init();
	//$summer.byId("content").innerHTML += "<h1 style='text-align: center'>Hello friends, welcome to touch the summer frame!</h1><h2 style='text-align: center'>The frame update at " +(new Date()).toLocaleString()+"</h2>";
};
/**
 * author:zhangjlt
 * date:2016年8月22日22:30:42
 */
var main = {
	/**
	 * bindEvent 页面事件
	 */
	bindEvent: function () {
		 $('#footer>a').click(function(){
		 	var a=['消息','应用','我'];
		 	$(this).addClass('active').siblings('.active').removeClass('active');
			var tar=$(this).attr('data-tar');
			$(tar).addClass('active').siblings('.active').removeClass('active');
			var num=$(this).index(); 
			$('#header h3').html(a[num]);
				
		});		 

	},
	init:function(){
		//1.初始化  加载应用界面	
		main.initMainPage();
	},
	//应用界面加载
	initMainPage:function(){
		//1.调用接口 返回数据
	
		//2.成功回调中处理数据 清空dom
		$("#apply").html("");
		//2.1 加载轮播图
		main.loadBanner();
		//2.2 成功回调中加载 用户信息
		var username = "王林";
		var userChang = "渡头肉鸡场";
		var userhtml = '<label class="um-label um-box-justify"><div style="padding-left: 15px;">'+userChang+'，'+ username+'，你好!</div> </label>';
		$("#apply").append(userhtml);
		
		
		//2.3 加载场舍数据
		main.loadChickenFarm();
		//2.4 加载应用图标
		main.loadapp();
		
	},
	loadapp:function(){
		var list = [
			{
				id:"1",
				data1:"存栏数",
				data2:"6000羽"
			},
			{
				id:"2",
				data1:"日龄",
				data2:"26天"
			},
			{
				id:"2",
				data1:"累计死淘数",
				data2:"25羽"
			},
			{
				id:"2",
				data1:"累计死淘数",
				data2:"25羽"
			}
		];
		var data = {
			id:"0",
			data1:"",
			data2:""
		}
		if(list.length%3 >0){
			list.push(data); 
		}
		if(list.length%3 >0){
			list.push(data); 
		}
		var html ='<div class="um-grid">';
		for(var i=0;i<list.length;i++){
			if(i%3 ==0){
				html +='<div class="um-grid-row tc">';
			}
			if(list[i].id !=0){

			
			html +='<div class="um-box-center">'
                  +' <a href="#" class="um-circle w70 h70 um-box-center um-bgc-blue click" >'             
                  +' <div>'                    
                  +' <img src="../img/poster.png" width=30 class="um-img-responsive" alt="">'                       
                  +' <div class="um-white f12"> 我要申报 </div>'                      
                  +'</div>'                          
                  +'</a>'                      
                  +' </div>'; 
			}  else{
				html +='<div></div>';
			}                 
			if(i%3==2){
				html +='</div>';
			}

		}
		html +='</div>';
		$("#apply").append(html);
		$(".click").click(function(){
		summer.openWin({
            "id" : 'feedList',
            "url" : 'html/feedList.html'
        });
		});
		
	},
	convertImgToBase64:function(url, callback, outputFormat){
    var canvas = document.createElement('CANVAS'),
        ctx = canvas.getContext('2d'),
        img = new Image;
    img.crossOrigin = 'Anonymous';
    img.onload = function(){
        canvas.height = img.height;
        canvas.width = img.width;
        ctx.drawImage(img,0,0);
        var dataURL = canvas.toDataURL(outputFormat || 'image/png');
        callback.call(this, dataURL);
        canvas = null; 
    };
    img.src = url;
},
	loadChickenFarm:function(){
		var list = [
			{
				id:"1",
				data1:"存栏数",
				data2:"6000羽"
			},
			{
				id:"2",
				data1:"日龄",
				data2:"26天"
			},
			{
				id:"2",
				data1:"累计死淘数",
				data2:"25羽"
			}
		];
		var data = {
			id:"0",
			data1:"",
			data2:""
		}
		if(list.length%2 >0){
			list.push(data); 
		}
		var html = '<div style="margin-top: 10px">';
		for(var i =0;i<list.length;i++){
			if(i%2==0){

				html += '<div class="um-row  um-bgc-white">'
                       +'	<div class="um-xs-6 um-bgc-white p10 um-border-right">'
                       +'		<p class="f14">'+list[i].data1+'</p>'		
                       +'		<p class="um-red f14">'+list[i].data2+'</p>'		
                       +'	</div>';	           	
			}else{
				if(list[i].id!=0){
					html +='	<div class="um-xs-6 um-bgc-white p10">'
					      +'		<p class="f14">'+list[i].data1+'</p>'
                      	  +'		<p class="um-red f14">'+list[i].data2+'</p>'
                      	  +'	</div>'	;
				}else{
					html +='	<div class="um-xs-6 um-bgc-white p10">' 
						  +'	</div>'

				}
				html+='</div>';
			}
		}
		html +='</div>';
		$("#apply").append(html);

	},
	loadBanner:function(){
		var html ='<div class="um-row"><div id="iSlider-wrapper" class="iSlider-wrapper"></div></div>';
		$("#apply").append(html);

		var list = [
			{
				content: "../img/g1.jpg"
			}, 
			{
				content: "../img/g2.jpg"
			}, 
			{
				content: "../img/g3.jpg"
			}
		];
		var islider = new iSlider({
			type: 'pic',
			data: list,
			dom: document.getElementById("iSlider-wrapper"),
			isLooping: true,
			animateType: 'default',
			isAutoplay: true,
			animateTime: 800
		});
		islider.addDot();
	},
	// 我  界面加载
	initMyPage:function(){

	},
	// 消息界面加载
	initMessagePage:function(){

	}
	
};

	
